Skip to content

Conversation

@karlseguin
Copy link
Collaborator

Previously, MutationObserver callbacks where called using the jsCallScopeEnd mechanism. This was slow and resulted in records split in a way that callers might not expect. jsCallScopeEnd has been removed.

The new approach uses the loop.timeout mechanism, much like a window.setTimeout and only registers a timeout when events have been handled. It should perform much better.

Exactly how MutationRecords are supposed to be grouped is still a mystery to me. This new grouping is still wrong in many cases (according to WPT), but appears slightly less wrong; I'm pretty hopeful clients don't really have hard-coded expectations for this though.

Also implement the attributeFilter option of MutationObserver. (Github)

Previously, MutationObserver callbacks where called using the `jsCallScopeEnd`
mechanism. This was slow and resulted in records split in a way that callers
might not expect. `jsCallScopeEnd` has been removed.

The new approach uses the loop.timeout mechanism, much like a window.setTimeout
and only registers a timeout when events have been handled. It should perform
much better.

Exactly how MutationRecords are supposed to be grouped is still a mystery to me.
This new grouping is still wrong in many cases (according to WPT), but appears
slightly less wrong; I'm pretty hopeful clients don't really have hard-coded
expectations for this though.

Also implement the attributeFilter option of MutationObserver. (Github)
@karlseguin karlseguin merged commit 2aee580 into main Jul 8, 2025
10 checks passed
@karlseguin karlseguin deleted the mutation_observer_loop branch July 8, 2025 00:15
@github-actions github-actions bot locked and limited conversation to collaborators Jul 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants